<?php
$sel=$_POST['username']??'';
//$dbh=new PDO('mysql:host=localhost;dbname=gaofei','root','root');
//$page=$_GET['page']??1;
//echo $page;die;
//$limit=2;
//$start=($page-1)*$limit;
//$sql='select * from members limit '.$start.','.$limit;
//$arr=$dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC);
if($sel!='')
{
    $memcache_obj=memcache_connect('127.0.0.1',11211);
    $arr=$memcache_obj->get($sel);
    if($arr=='')
    {
        echo "没有缓存";
        $dbh=new PDO('mysql:host=localhost;dbname=gaofei','root','root');
        $sql="select * from members where username like '%$sel%' limit";
        $arr=$dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC);
        $memcache_obj->set($sel,$arr);
    }
}
else
{
    //echo "缓存成功";
    $dbh=new PDO('mysql:host=localhost;dbname=gaofei','root','root');
    $sql="select * from members where username like '%$sel%'";
    $arr=$dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC);
}
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
   <form method="post">
       <input type="text" name="username">
       <input type="submit" value="搜索">
   </form>
</body>
<table border="1">
    <tr>
        <td>id</td>
        <td>账号</td>
        <td>密码</td>
        <td>确认密码</td>
    </tr>
    <?php foreach($arr as $value){ ?>
        <tr>
            <td><?php echo $value['id']?></td>
            <td><?php echo $value['username']?></td>
            <td><?php echo $value['pwd']?></td>
            <td><?php echo $value['pwddd']?></td>
        </tr>
    <?php } ?>
</table>
</html>
